package com.test.controller;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.test.autocomplete.DummyDB;
import com.test.form.User1;

@Controller
public class UserController {
	private static DummyDB dummyDB=new DummyDB();
	
	@RequestMapping(value="/index1",method=RequestMethod.GET)
	public ModelAndView index(){
		User1 userForm=new User1();
		return new ModelAndView("user","userForm",userForm);
	}
	
	@RequestMapping(value = "/get_country_list",
			method = RequestMethod.GET,
			headers="Accept=*/*")
	public @ResponseBody List<String> getCountryList(@RequestParam("term") String query){
		List<String> countryList=dummyDB.getCountryList(query);
		return countryList;
	}
	
	@RequestMapping(value ="/get_tech_list",method=RequestMethod.GET,headers="Accept=*/*")
	@ResponseBody
	public List<String> getTechList(@RequestParam("term")String query) {
	List<String> countryList = dummyDB.getTechList(query);
	System.out.println("countryList:"+countryList);
	return countryList;
	}
}
